<?php global $options; ?>
<div id="sidebar">

    
<?php /*?><?php if ( !(is_home() || is_front_page()) && function_exists('dynamic_sidebar') && dynamic_sidebar(4) ) : else : endif;?>
<?php */?>


<?php
/**
* In base alle ultime richieste, il box di ricerca va inserito sempre nella sidebar
* anche in home page
* Agata 06.06.2009
*/






 //if (!(is_home() || is_front_page())) :?>
 
 
<?php
/**
* commentato il motore di ricerca nella sidebar
* Mirko 12.06.2009
*/ ?>
 
 
 
<!--	<div class="box_a">
<?php /*?>		<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(4) ): endif; ?>
<?php */?>    <span class="foot"></span>
    </div>
--><?php //endif; ?>

<?php
/**
* Spostato box pubblicitario sopra a Newsletter come da richiesta
* Agata 07.06.2009
*/ ?>

<?php if (!empty($options['adblock2'])) : ?>
<div class="box_a" id="widget_A">

	<h2><?php print ADVERTISEMENT; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div>
	
	<p class="aligncenter"><?php print $options['adblock2']; ?></p>
	
	</div>

<span class="foot"></span>
</div>
<?php endif; ?>



<?php
/**
* Box Newsletter con servizio
* Aweber
* Agata 07.06.2009
*/
?>

    <div class="box_a" id="aweber">
    <h2>Iscriviti alla nostra NewsLetter<a href="#minimize" class="Sminimize"></a><a href="#close" class="Sclose"></a></h2>
        <p>Per rimanere sempre aggiornato sui contenuti del nostro portale, iscriviti gratuitamente alla newsletter di avvocato.it</p>
        
	    <form id="nl" method="post" action="http://www.aweber.com/scripts/addlead.pl" target="_new">
        <input type="hidden" name="meta_web_form_id" value="142285841">
        <input type="hidden" name="meta_split_id" value="">
        <input type="hidden" name="unit" value="avvocato">
        <input type="hidden" name="redirect" value="http://www.avvocato.it" id="redirect_30a91bbeb653b70e0c7c879ba31fbb2b">
        <input type="hidden" name="meta_redirect_onlist" value="">
        <input type="hidden" name="meta_adtracking" value="">
        <input type="hidden" name="meta_message" value="1">
        <input type="hidden" name="meta_required" value="name,from">
        <input type="hidden" name="meta_forward_vars" value="0">
        <table>
        <tr><td colspan=2><center></center></td></tr>
        <tr><td>Nome:</td><td><input id="nl_name" type="text" name="name" value="" size="20"></td></tr>
        <tr><td>E-mail:</td><td><input id="nl_mail" type="text" name="from" value="" size="20"></td></tr>
            <tr><td colspan=2><center></center></td></tr>
        <tr><td align="right" colspan="2"><input id="nl_button" type="submit" name="submit" value="Voglio iscrivermi"></td></tr>
        </table>
        </form>
        
        <img src="http://forms.aweber.com/form/displays.htm?id=jCxMTBysHCyM" border="0" />
        
    <span class="foot"></span>
    </div>
    

<?php if (is_page()) : ?>
<?php
$pages = get_pages('child_of='.$post->ID);
if (count($pages) > 0) {
?>
<ul class="widgets">
	<li><h2>Sub Pages<a href="#minimize" class="Wminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Wclose"></a><?php endif; ?></h2>
		<ul>
		<?php
		foreach($pages as $child) {
		print '<li>';
		print '<a href="'.get_permalink($child->ID).'" title="'.$child->post_title.'">';
		print $child->post_title;
		print '</a>';
		print '</li>';
		}
		?>
		</ul>
	<span class="foot"></span></li>
</ul>
<?php
}
?>
<?php endif; ?>

<?php if (is_single()) : ?>
<?php if (is_page()) $tle = PAGE; else $tle = POST; ?>

<?php global $user_ID; if( $user_ID ) : ?>
<?php if(current_user_can('level_10')) : ?>
<div class="box_a">

	<h2><?php print SITE_ADMIN; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<ul class="admin_menu">
	
	<li><?php edit_post_link(EDIT_ARTICLE, '', ''); ?></li>
	<li><strong><?php wp_loginout(); ?></strong></li>
	
	</ul>

<span class="foot"></span>
</div>
<?php endif; ?>
<?php endif; ?>

<div class="box_a">

	<h2><?php print THE_AUTHOR; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div class="autho">
	
	<span class="side_avatar"><?php echo get_avatar(get_the_author_email(), '40'); ?></span>
	<p><?php print THIS_TEXT; ?> <?=$tle?> <?php print WAS_WRITTEN_BY; ?> <strong><?php the_author(); ?></strong> <?php print ON_TEXT; ?> <?php the_time('l, F j, Y, G:i'); ?>. <strong><?php the_author_posts_link(); ?></strong> <?php print HAS_WRITTEN; ?> <strong><?php the_author_posts(); ?> <?php print POSTS; ?></strong> <?php print ON_THIS_BLOG; ?>.</p>

	</div>

<span class="foot"></span>
</div>

<div class="box_a">

	<h2><?php print INFORMATION; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<ul class="admin_menu">
	
	<?php if (is_single()) : ?><li class="ico_categories"><?php print POSTED; ?> <?php print IN_TEXT; ?> <?php the_category(', '); ?></li><?php endif; ?>
	<li class="ico_comments"><?php print THIS_TEXT; ?> <?=$tle?> <?php print HAS_TEXT; ?> <?php comments_number('<em>'.NO_COMMENTS_YET.'</em>','<a href="#comments"><strong>'.ONE_COMMENT.'</strong></a>','<a href="#comments"><strong>'.MORE_COMMENTS.'</strong></a>'); ?>. <a href="#respond"><strong><?php print WRITE; ?></strong></a> <?php print YOUR_OWN_COMMENT; ?>.</li>
	<?php if(function_exists('the_views')) { print '<li class="ico_views"><strong>'; the_views(); print '</strong> '.VIEWS_ON_THIS.' '.$tle.'</li>'; } ?>
	<?php if(function_exists('the_ratings')) { print '<li class="ico_ratings">'.USER_RATINGS; the_ratings(); print '</li>'; } ?>
	<?php if(function_exists('wp_print')) { print '<li class="ico_print">'; print print_link(); print '</li>'; } ?>
	
	</ul>

<span class="foot"></span>
</div>

<?php endif; ?>

<?php if (is_category()) : ?>
<div class="box_a">

	<h2><?php print HOT_TOPICS; ?> <?php print IN_TEXT; ?> <?php print get_cat_name($cat); ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div style="padding:0 0 0 0">
	
	<ul id="Ctabs" class="tabs">
		<li><a href="#most-viewed" rel="mostv" class="selected"><?php print MOST_VIEWED; ?></a></li>
		<li><a href="#top-rated" rel="trated"><?php print TOP_RATED; ?></a></li>
		<li><a href="#most-rated" rel="mrated"><?php print MOST_RATED; ?></a></li>
	</ul><div class="clear"></div>
	
	<ul id="mostv" class="tabcontent">
	<?php get_most_viewed_category($cat, 'post', 10); ?>
	</ul>
	
	<ul id="trated" class="tabcontent">
	<?php get_highest_rated_category($cat, 'post', 0, 10); ?>
	</ul>

	<ul id="mrated" class="tabcontent">
	<?php get_most_rated_category($cat, 'post', 0, 10); ?>
	</ul>
	
	<script type="text/javascript">
	var Ctabs=new ddtabcontent("Ctabs")
	Ctabs.setpersist(false)
	Ctabs.setselectedClassTarget("link")
	Ctabs.init()
	</script>
	
	</div>

<span class="foot"></span>
</div>
<?php endif; ?>


<?php
/**
* Iscrizione newsletter prevista da template COMMENTATA
* Agata 07.06.2009
*/
?>

<!--<div class="box_a" id="widget_S">

	<h2><?php print SUBSCRIPTION; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div>
	
	<p><?php print SUBSCRIBE_BY; ?> <strong><?php print RSS_FEED; ?></strong> <?php print OR_TEXT; ?> <?php print BY_TEXT; ?> <strong><?php print EMAIL; ?></strong> <?php print TO_RECEIVE_NEWS; ?>.</p>
	<p><a href="<?php bloginfo('rss2_url'); ?>" id="feedlink"><?php print SUBSCRIBE_TO; ?> <?php print RSS_FEED; ?></a></p>
	<form id="feedform" method="post" action="http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $options['feed_name']?>">
	<fieldset>
	<input type="text" id="feedemail" name="email" value="<?php print ENTER_YOUR_EMAIL; ?>" />
	<input type="hidden" value="<?php echo $options['feed_name']?>" name="uri"/>
	<input type="hidden" name="loc" value="en_US"/>
	<input type="submit" id="feedbutton" value="" />
	</fieldset>
	</form>
	
	</div>

<span class="foot"></span>
</div>-->

	<?php 
    /**
    * Inserimento Calendario Eventi nella Sidebar.
    * Agata, 6.06
    */?>
    
    <div class="box_a" id="widget_S">
        <h2><a href="http://www.avvocato.it/eventi-e-formazione/eventi" title="calendario eventi">Calendario Eventi</a>
        <a href="#minimize" class="Sminimize"></a>
        <a href="#close" class="Sclose"></a></h2>
        <div>
                <?php ec3_get_calendar(); ?>
        </div>
       
        <div class="cal-event-list">
        <h3>I prossimi eventi</h3>
        <?php ec3_get_events(
			'5',                               // limit
			'%DATE%: <a href="%LINK%">%TITLE%</a>', // template_event
			''                                      // template_day
		);
		?>

        </div>
        <span class="foot"></span>
    </div>



<?php if (!is_category() && !is_page()) : ?>
<div class="box_a" id="widget_T">

	<h2><?php print HOT_TOPICS; ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div style="padding:0 0 0 0">
	
	<ul id="tabs" class="tabs">
		<li><a href="#recent-topics" rel="recent" class="selected"><?php print RECENT_TOPICS; ?></a></li>
		<li><a href="#most-viewed" rel="viewed"><?php print MOST_VIEWED; ?></a></li>
		<li><a href="#most-discussed" rel="discussed"><?php print MOST_DISCUSSED; ?></a></li>
	</ul><div class="clear"></div>
	
	<ul id="recent" class="tabcontent">
	<?php wp_get_archives('type=postbypost&limit='.$options['recent_num'].'&format=html'); ?>
	</ul>

	<ul id="viewed" class="tabcontent">
	<?php if (function_exists('get_most_viewed')): ?>
	<?php get_most_viewed('post', $options['viewed_num']); ?>
	<?php endif; ?>
	</ul>
	
	<ul id="discussed" class="tabcontent">
	<?php
	$now = gmdate("Y-m-d H:i:s",time());
	$ap = $options['discussed_num'];
	$popularposts = "SELECT ID, post_title, post_date, comment_count, COUNT($wpdb->comments.comment_post_ID) AS 'popular' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY popular DESC LIMIT $ap";
	$posts = $wpdb->get_results($popularposts);
	$popular = '';
	if($posts){
	foreach($posts as $post){
	$post_title = stripslashes($post->post_title);
	$post_date = stripslashes($post->post_date);
	$comments = stripslashes($post->comment_count);
	$guid = get_permalink($post->ID);
	$popular .= '<li><a href="'.$guid.'#comments" title="'.$post_title.'">'.$post_title.' <span>'.DISCUSSED.' '.$comments.' '.TIMES.'</span></a></li>';
	}
	}echo $popular;
	?>
	</ul>
	
	<script type="text/javascript">
	var tabs=new ddtabcontent("tabs")
	tabs.setpersist(false)
	tabs.setselectedClassTarget("link")
	tabs.init()
	</script>
	
	</div>

<span class="foot"></span>
</div>
<?php endif; ?>


<?php
/**
* commentato il box dei video
* Mirko 12.06.2009
*/ ?>





<?php /*?>

<?php if ($options['videose'] == true) : ?>
<?php $videos = new WP_query(); $videos->query('showposts=1&cat='.$options['videos']); ?>
<?php global $wp_query; $wp_query->in_the_loop = true; ?>
<?php if ($videos->have_posts()) : ?>

<div class="box_a" id="widget_V">

	<?php while ($videos->have_posts()) : $videos->the_post(); ?>
	<h2><?php the_title(); ?><a href="#minimize" class="Sminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Sclose"></a><?php endif; ?></h2>
	<div>
	<?php show_video(304,204); ?>
	<p><a href="<?php print get_category_link($options['videos']); ?>"><strong><?php print SEE_ALL_VIDEOS; ?></strong></a></p>
	</div>
	<?php endwhile; ?>

<span class="foot"></span>
</div>

<?php endif; ?>
<?php endif; ?>


<?php */?>

<ul class="widgets">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

<?php
/**
* In base alle ultime richieste, il box di ricerca va inserito sempre nella sidebar
* anche in home page
* Agata 06.06.2009
*/ ?>
	<!--<li><h2>Recent Posts<a href="#minimize" class="Wminimize"></a><?php if ($options['closewidget'] == 1) : ?><a href="#close" class="Wclose"></a><?php endif; ?></h2>
	<ul><?php wp_get_archives('type=postbypost&limit=5'); ?></ul>
	<span class="foot"></span></li>-->

<?php endif; ?>
</ul>

<div class="clear"></div>



<?php
/**
* commentato i box per archivi e tags
* Mirko 12.06.2009
*/ ?>





<!--<ul class="widgetsl">
<?php /*?><?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
<?php */?>
	<li><h2>Popular Tags</h2>
	<ul><li><?php /*?><?php wp_tag_cloud('smallest=8&largest=22&number=22'); ?><?php */?></li></ul>
	<span class="foot_s"></span></li>

<?php /*?><?php endif; ?>
<?php */?></ul>
-->
<!--<ul class="widgetsr">
<?php /*?><?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(3) ) : else : ?>
<?php */?>
	<li><h2>Archives</h2>
	<ul><?php /*?><?php wp_get_archives('type=monthly&limit=12'); ?><?php */?></ul>
	<span class="foot_s"></span></li>

<?php /*?><?php endif; ?><?php */?>
</ul>
-->
<div class="clear"></div>

</div><div class="clear"></div>